#!/usr/bin/env python
# -*- coding: utf-8 -*-

from typing import List

from .itemBuilder import Item, ItemBuilder
from .play import Play
from .baseBuilder import BaseBuilder


class PlayBuilder(BaseBuilder):
    def __init__(self):
        # 播放节目集合
        self.item_list: List[Item] = []
        # 播放节目对应的直接指令, 暂时没用到
        self._push_protocol: str = ''
        # 节目id，一般不指定，默认1
        self._play_id: int = 1

    def add_item_builder(self, builder: ItemBuilder) -> 'PlayBuilder':
        self.item_list.append(builder.build())

        return self

    def build(self) -> Play:
        return Play(**self.to_dict())

    @property
    def push_protocol(self) -> str:
        return self._push_protocol

    @push_protocol.setter
    def push_protocol(self, push_protocol: str) -> None:
        self._push_protocol = push_protocol

    @property
    def play_id(self) -> int:
        return self._play_id

    def set_play_id(self, play_id: int) -> 'PlayBuilder':
        self._play_id = play_id
        return self
